/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Santiago.Escobar.M
 */
@Entity
@Table(name = "modelovehiculo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Modelovehiculo.findAll", query = "SELECT m FROM Modelovehiculo m"),
    @NamedQuery(name = "Modelovehiculo.findByMarca", query = "SELECT m FROM Modelovehiculo m WHERE m.modelovehiculoPK.marca = :marca"),
    @NamedQuery(name = "Modelovehiculo.findByModelo", query = "SELECT m FROM Modelovehiculo m WHERE m.modelovehiculoPK.modelo = :modelo")})
public class Modelovehiculo implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ModelovehiculoPK modelovehiculoPK;
    @JoinColumn(name = "marca", referencedColumnName = "marca", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Marcavehiculo marcavehiculo;
    @OneToMany(mappedBy = "modelovehiculo")
    private Collection<Vehiculo> vehiculoCollection;

    public Modelovehiculo() {
    }

    public Modelovehiculo(ModelovehiculoPK modelovehiculoPK) {
        this.modelovehiculoPK = modelovehiculoPK;
    }

    public Modelovehiculo(String marca, String modelo) {
        this.modelovehiculoPK = new ModelovehiculoPK(marca, modelo);
    }

    public ModelovehiculoPK getModelovehiculoPK() {
        return modelovehiculoPK;
    }

    public void setModelovehiculoPK(ModelovehiculoPK modelovehiculoPK) {
        this.modelovehiculoPK = modelovehiculoPK;
    }

    public Marcavehiculo getMarcavehiculo() {
        return marcavehiculo;
    }

    public void setMarcavehiculo(Marcavehiculo marcavehiculo) {
        this.marcavehiculo = marcavehiculo;
    }

    @XmlTransient
    public Collection<Vehiculo> getVehiculoCollection() {
        return vehiculoCollection;
    }

    public void setVehiculoCollection(Collection<Vehiculo> vehiculoCollection) {
        this.vehiculoCollection = vehiculoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (modelovehiculoPK != null ? modelovehiculoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Modelovehiculo)) {
            return false;
        }
        Modelovehiculo other = (Modelovehiculo) object;
        if ((this.modelovehiculoPK == null && other.modelovehiculoPK != null) || (this.modelovehiculoPK != null && !this.modelovehiculoPK.equals(other.modelovehiculoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.Modelovehiculo[ modelovehiculoPK=" + modelovehiculoPK + " ]";
    }
    
}
